//
//  GBWebViewVM.m
//  GuiJuWo
//
//  Created by chenguibang on 16/3/24.
//  Copyright © 2016年 chenguibang. All rights reserved.
//

#import "GBWebViewVM.h"
#import "GJWBaseRequest.h"
@implementation GBWebViewVM
-(void)loadUrlOnPost:(NSString *)url{
    GJWBaseRequest *BaseRequest = [[GJWBaseRequest alloc]init];
    NSString *serverUrl = [[BaseRequest.baseUrl stringByReplacingOccurrencesOfString:@"json" withString:@"appweb"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString *destUrl = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:serverUrl]];
    NSString *sessionId = [[NSUserDefaults standardUserDefaults] objectForKey:@"sessionId"] == [NSNull null] ? [NSNull null] :[[NSUserDefaults standardUserDefaults] objectForKey:@"sessionId"];
    NSString *postBody = [NSString stringWithFormat:@"sessionId=%@&destUrl=%@&fromid=%@",sessionId,destUrl,@"app"];
    [request setTimeoutInterval:15];
    [request setCachePolicy:NSURLRequestReloadRevalidatingCacheData];
    [request setHTTPMethod: @"POST"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody: [postBody dataUsingEncoding: NSUTF8StringEncoding]];
    self.requst = request;
}

-(void)loadNormalUrl:(NSString *)url{
    NSString *destUrl = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:destUrl]];
    [request setTimeoutInterval:15];
    self.requst = request;
}



@end
